#pragma once

#ifndef __THREADCACHE_H__
#define __THREADCACHE_H__
#include "Common.h"

class ThreadCache
{
public:
	void *Allocate(size_t size);
	void Deallocate(void *ptr, size_t size);
	void *FetchFromCentralCache(size_t index, size_t size);
	void ListTooLong(FreeList &list, size_t size);

private:
	FreeList _freeList[NFREELIST];
};

//TLS thread local storage(线程局部缓存)

#if defined(_WIN64) || defined(_WIN32)
static _declspec(thread) ThreadCache *TLSThreadCache = nullptr;
#else
static __thread ThreadCache *TLSThreadCache = nullptr;
#endif

#endif